#pragma once

#include "GTAAppInc.h"

class Timer
{
	typedef double timer_t;
public:
	Timer(void);
	~Timer(void);

	timer_t		Update (timer_t fLockFPS = 0.0);
	void		Reset (void);
	void		Stop (void);
	void		Resume (void);
	void		Advance (timer_t timeStep = 0.1);

	bool		IsStopped (void) const;

	timer_t		GetTimeElapsed(void) const;	
	int			GetFrameRate(wchar_t * buffer, size_t sizeInChars) const;
	int			GetFrameRate(char * buffer, size_t sizeInChars) const;

private:
	bool		mUsingPerformanceCounter;	// Has Performance Counter
	timer_t		mTimeScale;					// Amount to scale counter
	timer_t		mTimeElapsed;				// Time elapsed since previous frame

	int			mFrameRate;					// Stores current framerate
	int			mFPSFrameCount;				// Elapsed frames in any given second

	int			mStopCount;
	timer_t		mFPSTimeElapsed;			// How much time has passed during FPS sample

	timer_t		mTimeNow;					// Current Performance Counter
	timer_t		mTimeLast;					// Performance Counter last frame
	timer_t		mTimeStop;					// Not implemented yet.
	timer_t		mTimeFreq;					// Performance Frequency

	timer_t		GetTime(void);
	timer_t		GetCurrentTick (void) const;
};

#include "timer.inl"

